home *** CD-ROM | disk | FTP | other *** search
/ Mac Easy 2010 May / Mac Life Ubuntu.iso / casper / filesystem.squashfs / usr / share / python-support / gnome-orca / orca / acss.py < prev    next >
Encoding:
Python Source  |  2009-04-13  |  3.1 KB  |  100 lines

  1. # Orca
  2. #
  3. # Copyright 2005-2008 Google Inc.
  4. # Portions Copyright 2007-2008, Sun Microsystems, Inc.
  5. #
  6. # This library is free software; you can redistribute it and/or
  7. # modify it under the terms of the GNU Library General Public
  8. # License as published by the Free Software Foundation; either
  9. # version 2 of the License, or (at your option) any later version.
  10. #
  11. # This library is distributed in the hope that it will be useful,
  12. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  14. # Library General Public License for more details.
  15. #
  16. # You should have received a copy of the GNU Library General Public
  17. # License along with this library; if not, write to the
  18. # Free Software Foundation, Inc., Franklin Street, Fifth Floor,
  19. # Boston MA  02110-1301 USA.
  20. #
  21. """ACSS --- Aural CSS.
  22.  
  23. Class ACSS defines a simple wrapper for holding ACSS voice
  24. definitions.  Speech engines implement the code for converting
  25. ACSS definitions into engine-specific markup codes.
  26.  
  27. """
  28.  
  29. __id__ = "$Id: acss.py 4573 2009-02-18 01:27:04Z wwalker $"
  30. __author__ = "T. V. Raman"
  31. __version__ = "$Revision: 4573 $"
  32. __date__ = "$Date: 2009-02-17 20:27:04 -0500 (Tue, 17 Feb 2009) $"
  33. __copyright__ = "Copyright (c) 2005-2008 Google Inc."
  34. __license__ = "LGPL"
  35.  
  36. class ACSS(dict):
  37.  
  38.     """Holds ACSS representation of a voice."""
  39.  
  40.     FAMILY        = 'family'
  41.     RATE          = 'rate'
  42.     GAIN          = 'gain'
  43.     AVERAGE_PITCH = 'average-pitch'
  44.     PITCH_RANGE   = 'pitch-range'
  45.     STRESS        = 'stress'
  46.     RICHNESS      = 'richness'
  47.     PUNCTUATIONS  = 'punctuations'
  48.  
  49.     # A value of None means use the engine's default value.
  50.     #
  51.     settings = {
  52.         FAMILY :        None,
  53.         RATE :          50,
  54.         GAIN :          10,
  55.         AVERAGE_PITCH : 5,
  56.         PITCH_RANGE :   5,
  57.         STRESS :        5,
  58.         RICHNESS :      5,
  59.         PUNCTUATIONS :  'all'
  60.     }
  61.  
  62.     def __init__(self, props=None):
  63.         """Create and initialize ACSS structure."""
  64.         dict.__init__(self)
  65.         props = props or {}
  66.         for k in props:
  67.             if k in ACSS.settings:
  68.                 # Do a 'deep copy' of the family.  Otherwise,
  69.                 # the new ACSS shares the actual data with the
  70.                 # props passed in.  This can cause unexpected
  71.                 # side effects.
  72.                 #
  73.                 if k == ACSS.FAMILY:
  74.                     self[k] = {}
  75.                     for j in props[k].keys():
  76.                         self[k][j] = props[k][j]
  77.                 else:
  78.                     self[k] = props[k]
  79.  
  80.     def __setitem__ (self, key, value):
  81.         """Update name when we change values."""
  82.         dict.__setitem__(self, key, value)
  83.  
  84.     def __delitem__(self, key):
  85.         """Update name if we delete a key."""
  86.         dict.__delitem__(self, key)
  87.  
  88.     def updateName(self):
  89.         """Update name based on settings."""
  90.  
  91.     def name(self):
  92.         _name = 'acss-'
  93.         names = self.keys()
  94.         if names:
  95.             names.sort()
  96.             for  k in names:
  97.                 _name += "%s-%s:" % (k, self[k])
  98.         _name = _name[:-1]
  99.         return _name
  100.